class Solution(object):
    def numberOfBeams(self, bank):
        last = 0
        ans = 0
        for b in bank:
            num = b.count('1')
            if num:
                ans += num * last
                last = num
        return ans
